< previous page page_342 next page >

Page 342
Listing 9.15. conntinued
    MsgBox strMsg, vbInformation, "CreateTable"
    '
    ' clean up
    db.Close
    ws.Close
    Set pr = Nothing
    Set td = Nothing
    Set db = Nothing
    Set ws = Nothing
    '
    Exit Sub
    '
LocalErr:
    strMsg = strMsg & "<err>"
    Resume Next
    '
End Sub
The code in Listing 9.15 creates a new database (erasing any old one first), creates a new table object, creates a single field object for the table, and then appends the new objects to their respective collections. Finally, the properties of the new table are displayed. Save and run the project. Check your results against Figure 9.14.
0342-01.jpg
Figure 9.14.
The results of adding a new table.
Modifying and Deleting Existing Tables
You can add new fields or delete existing fields by using the Append or Delete methods on the TableDef object. Add a command button with the Name property cmdModifyTable and a Caption property of Modify Table. Add the code in Listing 9.16 to the cmdModifyTable_Click event.

 
< previous page page_342 next page >

If you like this book, buy it!